package com.sanpu.kxe.business.main.view;

import android.app.Activity;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;

import com.sanpu.kxe.R;
import com.sanpu.kxe.base.BaseTitleActivity;
import com.sanpu.kxe.business.main.provider.MainOpenProvider;
import com.sanpu.kxe.common.interfaces.CommonConfig;
import com.sanpu.kxe.common.view.InputPasswordView;
import com.sanpu.kxe.module.dialog.GlobalDialog;

import butterknife.Bind;

/**
 * Description：设置支付密码第一步
 * Created by 薛勇军 on 2019/3/20.
 */

public class SetPayPwdOneActivity extends BaseTitleActivity {

    @Bind(R.id.content)
    InputPasswordView inputPasswordView;

    @Override
    protected int getLayoutResID() {
        return R.layout.activity_set_pay_password;
    }

    @Override
    protected void initView() {
        super.initView();
        commonTitle.setTitle("支付密码");
        inputPasswordView.setTitle("请设置支付密码");
    }

    @Override
    protected void onResume() {
        super.onResume();
        inputPasswordView.clearPsw();
    }

    @Override
    protected void setListener() {
        super.setListener();
        inputPasswordView.setOnCompleteClickListener(new InputPasswordView.OnCompleteClickListener() {
            @Override
            public void completeClick(String s) {
                if (!TextUtils.isEmpty(s) && s.length() == 6) {
                    MainOpenProvider.getInstance().openSetPayPwdSecondActivity(
                            mContext, s, CommonConfig.REQUESTCODE_SETPAY_PASSWORD);
                }
            }
        });
        commonTitle.setLeftOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == CommonConfig.REQUESTCODE_SETPAY_PASSWORD && resultCode == Activity.RESULT_OK) {
            setResult(RESULT_OK);
            finish();
        }
    }

    @Override
    public void onBackPressed() {
        GlobalDialog dialog = new GlobalDialog(mContext).headerIcon(R.drawable.img_warm_prompt)
                .title("温馨提示")
                .content("请设置支付密码");
        dialog.show();
    }

    @Override
    protected boolean hasBindEventBus() {
        return false;
    }
}
